package tts.controller;

import java.io.File;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.interceptor.ServletRequestAware;

import com.opensymphony.xwork2.ActionSupport;


public class RedirectAction extends ActionSupport implements ServletRequestAware {

	//ATTRIBUTI
	private static final long serialVersionUID = 4238073274722805109L;
	private HttpServletRequest request;
	private String page;

	//GETTER & SETTER
	public void setServletRequest(HttpServletRequest request) {
		this.request = request;
	}
	public HttpServletRequest getServletRequest() {
		return this.request;
	}
	public String getPage() {
		return page;
	}
	public void setPage(String page) {
		this.page = page;
	}

	//EXECUTE
	public String execute() {
		File f = new File(request.getSession().getServletContext().getRealPath("/jsp/"+page+".jsp"));
		if(!(f.exists())){
			this.setPage("fzf");
		}
		return SUCCESS;
	}
}